package com.tool.write.simple;

import com.alibaba.excel.EasyExcel;
import com.tool.write.entity.Person;
import com.tool.write.entity.PersonIndex;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author niuyicong
 * @date 2024/10/19  0:13:49
 * @description 只写入指定的列
 */
public class SimpleIndexWrite {
    public static void main(String[] args) {

        String fileName = "个人信息index" + System.currentTimeMillis() + ".xlsx";

        EasyExcel.write(fileName, PersonIndex.class)
                .sheet("模板")
                .doWrite(() -> {
                    return data();
                });
    }

    public static List<PersonIndex> data(){
        List<PersonIndex> data = new ArrayList<>();
        PersonIndex person1 = new PersonIndex("niu",25,new Date(),"男");
        PersonIndex person2 = new PersonIndex("niuniu",26,new Date(),"男");
        PersonIndex person3 = new PersonIndex("niuniuniu",27,new Date(),"男");
        data.add(person1);
        data.add(person2);
        data.add(person3);
        return data;
    }
}
